/*
 * @Descripttion:
 * @version:
 * @Author: sueRimn
 * @Date: 2022-07-11 15:02:34
 * @LastEditors: sueRimn
 * @LastEditTime: 2022-08-09 16:29:14
 */
/**function Person(name, age) {
  this.name = name;
  this.age = age;
  this.say = function () {
    console.log("构造函数方法--- ", this.name, this.age);
  }
}
Person.prototype.sex = "女";
Person.prototype.color = ["yellow", "red", "blue"];
Person.prototype.hello = function () {
  console.log("原型对象方法---- hello ", this.sex);
}
let p1 = new Person("dlj1", 20);
let p2 = new Person("dlj2", 30);
console.log("p1 is ", p1);
console.log("p2 is ", p2);
p2.hello();
console.log("p1.color ", p1.color.join("/"));
console.log("person 原型对象 ", p1.__proto__, p1.constructor.prototype == p1.__proto__, p1.__proto__ == Person.prototype, Person.prototype.constructor == p1.constructor);
console.log("person 原型对象上级原型对象包含join方法 ", p1.color.__proto__.hasOwnProperty("join"));*/


/**function Person(name) {
  this.name = name || "父类";
  this.say = function () {
    console.log("父类构造函数方法--- ", this.name);
  }
}
Person.prototype.sex = "女";
Person.prototype.color = ["yellow", "red", "blue"];
Person.prototype.hello = function () {
  console.log("父类原型对象方法---- hello ", this.sex);
}
function Child(age) {
  this.age = age;
}
Child.prototype = new Person("dlj");
Child.prototype.constrctor = Child;
Child.prototype.address = "北京";
Child.prototype.cHello = function () {
  console.log("子类原型对象方法---- chello ", this.sex);
}
let chd1 = new Child("22");
console.log(chd1.say());
console.log(chd1.hello());
console.log(chd1.cHello());
console.log("age name sex --- ", chd1.age, chd1.name, chd1.sex);
console.log("chd1  ", chd1);
console.log("chd1.__proto__   ", chd1.__proto__);
console.log("chd1.__proto__.__proto__   ", chd1.__proto__.__proto__);
console.log("chd1.__proto__  has color is ", chd1.__proto__.hasOwnProperty("color"));
chd1.color.push("aa");
console.log(new Person().color);*/

/**function Person1(name) {
  this.name = name || "父类";
  this.job = ["job1", "job2"];
  this.say = function () {
    console.log("父类构造函数方法--- ", this.name);
  }
}
Person1.prototype.sex = "女";
Person1.prototype.color = ["yellow", "red", "blue"];
Person1.prototype.hello = function () {
  console.log("父类原型对象方法---- hello ", this.sex);
}
function Person2(name) {
  this.name2 = name || "父类2";
  this.job2 = ["job1", "job2"];
  this.say2 = function () {
    console.log("父类构造函数方法--- ", this.name2);
  }
}
Person2.prototype.sex2 = "女";
Person2.prototype.color2 = ["yellow", "red", "blue"];
Person2.prototype.hello2 = function () {
  console.log("父类原型对象方法---- hello ", this.sex2);
}
function Child(name, age) {
  Person1.call(this, name);
  Person2.call(this, name);
  this.age = age;
  this.hello3 = function () {
    console.log("子类构造函数方法--- ", this.age);
  }
}
// Child.prototype = Person1.prototype;
Child.prototype = Object.create(Person1.prototype);
Child.prototype.constrctor = Child;

Child.prototype.address = "北京";
Child.prototype.cHello = function () {
  console.log("子类原型对象方法---- chello ");
}
let chd1 = new Child("dlj", 11);
let chd2 = new Child("dlj1", 111);
console.log("chi1 is ", chd1);
console.log("chd1.__proto__ ", chd1.__proto__);
console.log("chd1.__proto__.__proto__  ", chd1.__proto__.__proto__);
chd1.job2.push("job3");
console.log("chd1.job2 ", chd1.job2, chd2.job2);
console.log("chd1.sex ", chd1.sex);
chd1.say2();
chd1.hello();
console.log("Child.prototype.__proto__ ", Child.prototype.__proto__);
console.log("Person1.prototype ", Person1.prototype);
console.log(Child.prototype.__proto__ == Person1.prototype);*/


// async function async1() {
//   console.log("async1 start");
//   await async2();
//   console.log("async1 end");
// }
// async function async2() {
//   console.log("async2");
// }
// async1();
// setTimeout(() => {
//   console.log("timeout");
// }, 0);
// new Promise(function (resolve) {
//   console.log("promise1");
//   resolve();
// }).then(function () {
//   console.log("promise2");
// });
// console.log("script end");

function showTbrw(val) {
  console.log("同步任务" + val);
}
showTbrw(1);
new Promise((resolve, reject) => {
  console.log("同步任务2---new Promise");
  resolve(1);
}).then((val) => {
  console.log("微任务1---promise.then");
}).finally(() => {
  console.log("微任务2---promise.finally");
})
console.log("同步任务3");
setTimeout(() => {
  console.log("宏任务1");
  new Promise((resolve, reject) => {
    console.log("同步任务5---new Promise");
    resolve(1);
  }).then((val) => {
    console.log("微任务5---promise.then");
  })
}, 500)
new Promise((resolve, reject) => {
  console.log("同步任务4---new Promise");
  resolve(1);
}).then((val) => {
  console.log("微任务3---promise.then");
}).finally(() => {
  console.log("微任务4---promise.finally");
})
setTimeout(() => {
  console.log("宏任务11");
}, 0)
//输出结果
// 同步任务1
// 同步任务2---new Promise
// 同步任务3
// 同步任务4---new Promise
// 微任务1---promise.then
// 微任务3---promise.then
// 微任务2---promise.finally
// 微任务4---promise.finally
// 宏任务11
// 宏任务1
// 同步任务5---new Promise
// 微任务5---promise.then
